#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1.5e5 + 5;

int n, m;
int a[N], k;
int sum[405][405];
void init() {
  k = sqrt(n);
  rep(i, 1, k) rep(j, 1, n) sum[i][j % i] += a[j];
}
void update(int pos, int val) {
  rep(i, 1, k) sum[i][pos % i] += val - a[pos];
  a[pos] = val;
}
int query(int p, int x) {
  if (p <= k) return sum[p][x % p];
  int res = 0;
  for (int i = x % p; i <= n; i += p) {  // if x % p == 0, a[0] = 0
    res += a[i];
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  init();
  while (m--) {
    char op;
    int x, y;
    cin >> op >> x >> y;
    if (op == 'A')
      cout << query(x, y) << endl;
    else
      update(x, y);
  }
  return 0;
}